 class Book {
    String name;
    String author;
    String company;
    String date;
    void setname(String d){
        this.name = d;
    }
    String getname(){
        return name;
    }

    void setauthor(String a){
        this.author = a;
    }
    String getauthor(){
        return author;
    }

    void setcompany(String b){
        this.company = b;
    }
    String getcompany(){
        return company;
    }

    void setdate(String c){
        this.date = c;
    }
    String getdate(){
        return date;
    }


    @Override
    public String toString(){//覆盖toString方法
        return "Book name="+name+",Book author="+author+",Book company="+company+",Book date="+date;
    }

    public boolean equals(Book a){//覆盖equals方法
        if (this.author == a.author&&this. name==a.name&&this.company==a.company&&this.date==a.date) return true;
        else return false;
    }

}

public class Bookshelf{
public static void main(String[]args){
    Book book1=new Book();
    book1.setname("Java2实用教程");
    book1.setauthor("耿祥义");
    book1.setcompany("清华大学出版社");
    book1.setdate("2017年5月");
    System.out.println(book1.toString());
    Book book2=new Book();
    book2.setname("汇编语言程序设计");
    book2.setauthor("钱晓捷");
    book2.setcompany("电子工业出版社");
    book2.setdate("2012年6月");
    System.out.println(book2.toString());
    Book book3=new Book();
    book3.setname("算法与数据结构");
    book3.setauthor("张乃孝");
    book3.setcompany("高等教育出版社");
    book3.setdate("2011年6月");
    System.out.println(book3.toString());
    System.out.println(book1.equals(book2));
}
}



